<!DOCTYPE html>
<html>
<head>
    <title>修改个人资料</title>
    {include file="common/inc_meta" /}
</head>
<body>
    <div id="wrapper">
    {include file="common/inc_menu" /}
        <div id="page-wrapper" class="gray-bg">
        {include file="common/inc_top" /}
        
        <!--内容 Begin-->
            <div class="row wrapper border-bottom white-bg page-heading" style="padding-top:20px;font-weight: normal;">
                <div class="col-lg-10">
                    <h2 style="margin-bottom:10px;">修改个人资料</h2>
                    <ol class="breadcrumb">
                        <li><a href="{$admin.index_page}">主页</a></li>
                        <li><a>账户</a></li>
                        <li class="active"><strong>修改资料</strong></li>
                    </ol>
                </div>
                <div class="col-lg-2"></div>
            </div>
            <div class="wrapper wrapper-content animated fadeInRight">


              <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content" style="padding:20px;">
                            <form method="get" class="form-horizontal" onsubmit="return false;">
                                <div class="form-group"><label class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-4"><input type="text" class="form-control" maxlength="10" id="vNickname" value="{$admin.nickname}"></div>
                                    <label class="col-sm-1 control-label">手机号码</label>
                                    <div class="col-sm-5"><input type="text" class="form-control"  placeholder="输入管理人员联系电话" id="vPhone" value=""></div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">密码</label>
                                    <div class="col-sm-2">
                                          <input type="password" class="form-control" maxlength="16" id="vPassword">
                                          <span class="help-block m-b-none">若不修改密码请留空即可</span>
                                    </div>
                                    <label class="col-sm-1 control-label">安全码</label>
                                    <div class="col-sm-2">
                                       <input type="text" class="form-control" maxlength="4" placeholder="4位安全码，留空则自动生成" id="vSafecode" value=""> <span class="help-block m-b-none">4位安全码，未重设登录密码请勿修改</span>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">性别</label>
                                   <div class="col-sm-3">
                                      <label class="checkbox-inline i-checks"> <input type="radio" value="1" name="usex" {if $admin.sex eq '1'}checked="true"{/if}> 男性</label>
                                      <label class="checkbox-inline i-checks"> <input type="radio" value="2" name="usex" {if $admin.sex eq '2'}checked="true"{/if}> 女性</label>
                                   </div>
                                   <label class="col-sm-2 control-label">最后登录</label>
                                   <div class="col-sm-5"><input type="text" class="form-control" value="{$admin.last_login_time|date='Y-m-d H:i'}"></div> 
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">头像</label>
                                    <div class="col-sm-4">
                                          <input type="text" class="form-control" placeholder="可直接引用以http://开头的图片连接" id="vImg" value="{$admin.img}">
                                          <span class="help-block m-b-none">可直接引用以http://开头的图片URL连接</span>
                                    </div>
                                    <label class="col-sm-1 control-label" style="padding-top:2px;" id="myImgDiv">
                                        <label title="点击开始上传文件" for="img_file" class="btn btn-success btn-sm">
                                           <input type="file" accept="image/*" name="img_file" id="img_file" class="hide" data-iptobj="vImg" data-imgobj="img_box"><i class="fa fa-upload"></i>&nbsp;&nbsp;上传
                                        </label>
                                    </label>
                                    <div class="col-sm-2" id="img_box">
                                       <!--{if $admin.img}-->
                                          <img src="{$admin.img}" style="width:30px;height:auto;"/> 
                                       <!--{/if}-->
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <a href="{$admin.index_page}" class="btn btn-white">返回</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <button class="btn btn-primary" type="button" id="saveButton">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            </div>
        <!--内容 End-->

        {include file="common/inc_footer" /}
        </div>
    </div>
<!-- Mainly scripts -->
{include file="common/inc_jsfile" /}

<!-- iCheck -->
<script src="__ADMIN__/js/plugins/iCheck/icheck.min.js"></script>
<script src="__STATIC__/ajaxfileupload.js?v={$site.version}"></script>
<script>
$(function(){
   $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
   });
   //保存
   $("#saveButton").click(function(){
     saveAction();
   });
   $('#vNickname').focus();
   $('#vNickname').select();
   //上传绑定事件
   $('#myImgDiv').find('input:file').on('change',function(b){
     if($(this).val() != '')
     {
       AjaxUploadFile({savedir:'admin',inputname:$(this).attr('name'),imgid:$(this).attr('id'),iptobj:$(this).data('iptobj'),imgobj:$(this).data('imgobj')});
     }
   });
});
//上传动作
function AjaxUploadFile(param)
{
  layer.msg('上传中，请稍候...', {icon: 16,time:50000,shade:[0.4,'#000000']});
  $.ajaxFileUpload({
      url: "{:url('admin/index/uploadpic')}", //用于文件上传的服务器端请求地址
      secureuri: false, //是否需要安全协议，一般设置为false
      fileElementId: param.imgid, //文件上传域的ID
      data:param, //要上传参数
      dataType:"json", //返回值类型 一般设置为json
      success: function(data)  //服务器成功响应处理函数
      {
        layer.closeAll();
        $("#" + param.iptobj).val(data.img_path);
        $("#" + param.imgobj).empty();
        $("#" + param.imgobj).append('<img src="' + data.img_url + '" style="width:50px;height:auto;"/>');
      },
      error: function (data, status, e)//服务器响应失败处理函数
      {
        layer.closeAll();
        layer.msg('上传出错：' + e, {time: 2000,anim: 6,shade:[0.4,'#000000']});
        return false;
      }
  });
}
//保存
function saveAction()
{
 var param = {};
 param.v_id = "{$admin.id}";
 param.v_nick_name = $.trim($('#vNickname').val());
 param.v_pwd = $.trim($('#vPassword').val());
 param.v_safecode = $.trim($('#vSafecode').val());
 param.v_phone = $.trim($('#vPhone').val());
 param.v_sex = $.trim($("input[name='usex']:checked").val());
 param.v_img = $.trim($('#vImg').val());
 if(param.v_nick_name.length <= 0)
 {
   $('#vNickname').focus();
   layer.msg('请填写您的姓名', {time: 2000,anim: 6,shade:[0.4,'#000000']});
   return false;
 }
 _Admin.ajax("{:url('admin/index/profile')}",param,function(d){
   if(d.err == '0')
   {
     $('#vNickname').focus();
     layer.msg(d.msg, {time: 1500,shade:[0.4,'#000000']});
   }else{
     layer.msg(d.msg, {time: 2000,anim: 6,shade:[0.4,'#000000']});
   }
 });  
}
</script>
</body>
</html>
